package edu.wuster.blog.mapper;

import edu.wuster.blog.entity.Collect;
import org.apache.ibatis.annotations.*;

import java.util.List;


@Mapper
public interface CollectMapper {
    @Select("select * from collect where is_delete = 0 and user_id = #{userId}")
    List<Collect> selectByUserId(Integer userId);

    @Select("select * from collect where id = #{id}")
    Collect selectById(Integer id);

    @Update("update collect set is_delete = 1 where id = #{id}")
    void deleteById(Integer id);

    //@Insert("insert into collect(user_id, blog_id, title) values (#{userId},#{blogId},#{title})")
    void addCollect(Collect collect);

    @Update("update collect set is_delete = 0 where id = #{id}")
    void setIsDelete(Collect collect1);

    @Select("select * from collect where blog_id = #{blogId} and user_id = #{userId}")
    Collect selectByBlogIdUserId(Integer blogId, Integer userId);

    @Update("update collect set is_delete = 1 where blog_id = #{blogId}")
    void deleteByBlogId(Integer blogId);
}
